<?php

    session_start ();
    include 'function.php';
    display_header();
    if (isset($_SESSION['login']) && isset($_SESSION['mdp'])) {
    
    include 'include/Data.php';
    $req = mysql_query('SELECT Id_machine, Nom_machine, Started FROM machine_virtuel WHERE Id_machine = "'.$_GET['VM'].'"');
    $ligne = mysql_fetch_assoc($req);
    $nom = $ligne[Nom_machine];
    exec ('vboxmanage startvm "'.$nom.'" --type headless');
    $req2 = "UPDATE machine_virtuel SET Started=1 WHERE Id_machine='".$_GET['VM']."';";
    $ligne2 = mysql_query($req2,$connexion);
    header('Location: affiche.php');
    
    is_log();
    display_footer();
    } else { header("Refresh: 0; URL=index.php"); }
    
?>
